﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FirebirdSql.Data.FirebirdClient;

namespace University
{
    public partial class NAUKOVYI_PIDROZDIL : University.YSTANOVY
    {
        static string sqlSelect = "SELECT * FROM  NAUKOVYI_PIDROZDIL";
        FbDataAdapter da = new FbDataAdapter(sqlSelect, con);
        DataTable dt = new DataTable();

        public NAUKOVYI_PIDROZDIL()
        {
            InitializeComponent();

        }
        public NAUKOVYI_PIDROZDIL(TreeNode node, ContextMenuStrip s, string com, int id)
            : base(node, s, com, id)
        {
            InitializeComponent();
            node_id = Convert.ToInt32(mynode.Tag.ToString());

            da.Fill(dt);
            bindingSource1.DataSource = dt;

            richTextBox2.DataBindings.Add("Text", bindingSource1, "NAUKOVUJ_NAPRJAM");
            bindingSource1.Filter = "UNIQUE_NO =" + node_id;
            if (com == "Remove") { Remove("NAUKOVYI_PIDROZDIL"); }
        }
      
       
        public override void Remove(string name)
        {
            base.Remove(name);
        }

        public override void UpdateForm()
        {
            OpenCon();
            UpdateFild("NAUKOVYI_PIDROZDIL", "NAUKOVUJ_NAPRJAM", richTextBox2.Text);
            base.UpdateForm();

        }
        public override void InsertFild(string klas)
        {
            OpenCon();
            FbCommand cmdInsert = new FbCommand("INSERT INTO NAUKOVYI_PIDROZDIL(UNIQUE_NO,NAUKOVUJ_NAPRJAM) VALUES(@1,@2)", con);
            cmdInsert.Parameters.AddWithValue("1", textBox1.Text);
            cmdInsert.Parameters.AddWithValue("2", richTextBox2.Text);
            cmdInsert.ExecuteNonQuery();
            base.InsertFild(klas);
        }
        private void NAUKOVYI_PIDROZDIL_Load(object sender, EventArgs e)
        {

        }
    }
}